package com.example.proyectosoftware;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
public class ImageAdapter extends BaseAdapter {
    private Context mContext;
    private boolean bandera;

    public ImageAdapter(Context c, boolean ban) {
        mContext = c;
        bandera = ban;
    }

    public int getCount() {
    	if(bandera)
    		return mThumbIds.length;
    	else
    		return mThumb.length;
    }

    public Object getItem(int position) {
        return null;
    }

    public long getItemId(int position) {
        return 0;
    }

    // create a new ImageView for each item referenced by the Adapter
    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imageView;
        if (convertView == null) {  // if it's not recycled, initialize some attributes
            imageView = new ImageView(mContext);
            imageView.setLayoutParams(new GridView.LayoutParams(100, 100));
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            imageView.setPadding(8, 8, 8, 8);
            
        } else {
            imageView = (ImageView) convertView;
        }

        if (bandera)
        	imageView.setImageResource(mThumbIds[position]);
        else
        	 imageView.setImageResource(mThumb[position]);
        return imageView;
    }

    // references to our images
    private Integer[] mThumbIds = {
            R.drawable.m1, R.drawable.m2,
            R.drawable.m3, R.drawable.m4,
            R.drawable.m5, R.drawable.m6,
    };
    private Integer[] mThumb = {
            R.drawable.m1, R.drawable.m2,
            R.drawable.m3, R.drawable.m4,
    };
}